<#

.SYNOPSIS

Applies a board support package (BSP) to a Windows image File (a .WIM file) to create a Windows image provisioned for the specified board.

.DESCRIPTION

Create-DevboardImage will mount the specified Windows image file (WIM) and apply the contents of the specified board support package (BSP).  The drivers specified in the BSP will be installed, and any tools or firmware packages copied to the tools directory in the root of the image.

Additionally if the Windows 8.1 (or higher) WDK is installed on the system, the script will copy the tools from the kits into the tools directory in the image.

.PARAMETER SourcePath

The path to the Windows Image File to apply the board support package to.

.PARAMETER Index

If SourcePath points to a multi-image WIM, Index specifies the image within the WIM to modify.

Optional for a single-image WIM.

.PARAMETER BspManifest

The path to the manifest file for the BSP.  Generally this is found in the root of the BSP.

.PARAMETER Destination

The name of the Windows Image File that the script should create.  If not specified then SourcePath is modified in place.

.PARAMETER ToolsPath

The path to a directory of content that the caller wants copied into the Windows image.  The contents will be copied into \tools\other in the target image.

.PARAMETER WdkPath

The path to the root of the Windows Driver Kit.  If not specified then the script will use the WDKCONTENTROOT environment variable or the kits root specified in the registry to locate the WDK.

.PARAMETER AnswerFile

If specified the script will apply an AnswerFile to the Windows image while it is mounted.

.PARAMETER MountDir

Specifies the directory where the script should temporarily mount the Windows image while modifying it.  If not specified, a directory under the user's temporary directory is used.

.EXAMPLE

Apply the BSP to the second image in the WIM file, and save the resulting image in the local directory:

  Create-DevboardImage.ps1 -SourcePath d:\sources\install.wim -Index 2 -BspManifest .\BSP\BspManifest.xml -Destination .\modified.wim

.NOTES

This script must be run as administrator within an elevated powershell session.

This script is a wrapper around New-DevboardImage from the DevBoard module.

#>
#requires -RunAsAdministrator
#requires -Module Dism

param (
    # [parameter(Mandatory=$true)]
    $SourcePath,

    $Index,

    # [parameter(Mandatory=$true)]
    $BspManifest,

    $Destination,
    
    $ToolsPath,

    $WdkPath,

    $AnswerFile,

    $MountDir,
    
    [Switch]
    $WhatIf 
    )
    
Set-StrictMode -Version 3.0

Import-Module $PSScriptRoot\DevBoard
New-DevboardImage @PSBoundParameters
